package apps.project.upload;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;

import core.tool.common.StringHelper;
import core.tool.common.SystemInfo;

@Service("uploadFileService")
public class UploadFileService {
	
    @Autowired
	private UploadFileDao uploadFileDao;	
    
    public Page<UploadFileBean> findByAppid(String appid,int page,int size)  {
    	Sort sort=new Sort(Direction.DESC,"createtime");
		PageRequest pageReqeust=new PageRequest(page,size,sort);
		Page<UploadFileBean> result=uploadFileDao.findByAppid(appid, pageReqeust);
    	return result;
    }
    
    public void addFile(UploadFileBean uploadFileBean) {
    	uploadFileBean.setCreatetime(new Date());
    	uploadFileBean.setId(StringHelper.getUUID());
    	uploadFileDao.save(uploadFileBean);
    }
  
    
    public void downLoadFiles() {
    	
    }

}
